package com.itheima.manager;

import com.itheima.domain.SmsHomeRecommendSubject;
import com.itheima.service.db.SmsHomeRecommendSubjectService;
import com.itheima.util.R;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SmsHomeRecommendSubjectManager {
    @DubboReference
    SmsHomeRecommendSubjectService smsHomeRecommendSubjectService;

    /**
     * 营销-专题推荐-分页条件查询
     * @param pageNum
     * @param pageSize
     * @param subjectName
     * @param recommendStatus
     * @return
     */
    public PageBeanVo findRecommendSubjectByPage(Integer pageNum, Integer pageSize, String subjectName, Integer recommendStatus) {
        return smsHomeRecommendSubjectService.findRecommendSubjectByPage(pageNum,pageSize,subjectName,recommendStatus);
    }

    /**
     * 营销-专题推荐-添加专题
     * @param smsHomeRecommendSubjectList
     * @return
     */
    public R addSubject(List<SmsHomeRecommendSubject> smsHomeRecommendSubjectList) {
        return smsHomeRecommendSubjectService.addSubject(smsHomeRecommendSubjectList);
    }

    public R update(List<Long> ids, Integer recommendStatus) {
        for (Long id : ids) {
            smsHomeRecommendSubjectService.update(id,recommendStatus);
        }
        return R.success(null);
    }

    public R delete(List<Long> ids) {
        for (Long id : ids) {
            smsHomeRecommendSubjectService.delete(id);
        }
        return R.success(null);
    }

    public R updateSort(Long id, Integer sort) {
        smsHomeRecommendSubjectService.updateSort(id, sort);
        return R.success(null);
    }
}
